package com.lagou.user.mapper;

import com.lagou.user.entity.Token;
import org.apache.ibatis.annotations.*;

@Mapper
public interface TokenMapper {

    @Select("SELECT * FROM lagou_token WHERE token = #{token}")
    Token findByToken(@Param("token") String token);

    @Select("SELECT * FROM lagou_token WHERE email = #{email}")
    Token findByEmail(@Param("email") String email);

    @Insert("INSERT INTO lagou_token(email, token) VALUES(#{email}, #{token})")
    void add(@Param("email") String email, @Param("token") String token);

    @Update("UPDATE lagou_token SET token = #{token} WHERE email = #{email}")
    void update(@Param("token") String token, @Param("email") String email);
}
